﻿#if UNITY_EDITOR
using System;
using System.IO;
using System.Xml.Serialization;
/// <summary>
/// Project设定
/// </summary>
[XmlRoot("ESF_Xml_ProjectSetting")]
public class ESF_Xml_ProjectSetting : AbsESF_Xml
{
    /// <summary>
    /// Editor编辑器Extends文件夹
    /// </summary>
    [XmlElement("Editor编辑器Extends文件夹")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    [ESF_GUISeparator()]
    public string editorExtendFolder;

    /// <summary>
    /// Editor编辑器Bat文件夹
    /// </summary>
    [XmlElement("Editor编辑器Bat文件夹")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    [ESF_GUISeparator()]
    public string editorBatFolder;

    /// <summary>
    /// 模拟Behaviour根目录
    /// </summary>
    [XmlElement("模拟Behaviour根目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    [ESF_GUISeparator()]
    public string simulateBehaviourRootFolder;

    [XmlElement("配置热更新文件目录")]
    [ESF_ArrayMaxLength(typeof(ESF_enCopyToX))]
    public ESF_Xml_ProjectSetting_CopyToX[] copyToXs;

 

    /// <summary>
    /// 获得模拟Behaviour枚举类名
    /// </summary>
    /// <returns>枚举类名</returns>
    public string GetSimulateBehaviourEnumName()
    {
        return $"enESF_SimulateBehaviourEvent";
    }
    /// <summary>
    /// 获取UtlityName
    /// </summary>
    public string GetUtilityName { get { return "Utility"; } }

    public string GetCopyToX_UtilityFolder(ESF_enCopyToX _classify) {
        string path = Path.Combine(GetCopyToXFolder(_classify), GetUtilityName);
        return path;
    }
    /// <summary>
    /// 获得指定的CopyToX文件夹
    /// </summary>
    /// <param name="_classify">分类</param>
    /// <returns>CopyToX文件夹</returns>
    public string GetCopyToXFolder(ESF_enCopyToX _classify)
    {
        string result = string.Empty;
        if (copyToXs != null)
        {
            foreach (var key in copyToXs)
            {
                if (key.classify == _classify)
                {
                    result = key.srcFolder;
                    break;
                }
            }
        }
        return result;
    }

    /// <summary>
    /// 获得模拟Behaviour枚举根目录
    /// </summary>
    /// <returns>枚举根目录</returns>
    public string GetSimulateBehaviourEnumCopyToHFSrcFolder()
    {
        string result = string.Empty;
        if (copyToXs != null)
        {
            foreach (var key in copyToXs)
            {
                if (key.classify == ESF_enCopyToX.CopyToHF)
                {
                    result = key.srcFolder;
                    break;
                }
            }
        }
        return Path.Combine(result, "SimulateBehaviour").ESF_TransPathSeparatorCharToUnityChar();
    }

    /// <summary>
    /// 获得SpriteAtlas枚举文件夹
    /// </summary>
    /// <returns>SpriteAtlas枚举文件夹</returns>
    public string GetSpriteAtlasCopyToHFSrcFolder()
    {
        string result = string.Empty;
        if (copyToXs != null)
        {
            foreach (var key in copyToXs)
            {
                if (key.classify == ESF_enCopyToX.CopyToHF)
                {
                    result = key.srcFolder;
                    break;
                }
            }
        }
        return Path.Combine(result, "SpriteAtlas").ESF_TransPathSeparatorCharToUnityChar();
    }
}

[XmlRoot("ESF_Xml_ProjectSetting_CopyToX")]
public class ESF_Xml_ProjectSetting_CopyToX
{
    [XmlElement("类别")]
    [ESF_NoDuplicateValue()]
    public ESF_enCopyToX classify;

    /// <summary>
    /// Editor源文件夹
    /// </summary>
    [XmlElement("Editor源文件夹")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string srcFolder;

    /// <summary>
    /// 目标文件夹
    /// </summary>
    [XmlElement("目标文件夹")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string targetFolder;
}
#endif

